package com.galeno.yarn2;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/7/2417:55
 *  MR程序的reduce端 : 继承Reducer类
 *   KIN  map输出的单词   Text
 *   VIN  map输出的1      IntWritable
 *   KOUT  单词     Text
 *   VOUT  总次数     IntWritable
 */
public class WordCountReducer extends Reducer<Text, IntWritable,Text,IntWritable> {
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int count=0;
        for (IntWritable value : values) {
            count++;
        }
        context.write(key,new IntWritable(count));
    }
}
